package com.cloudkinto.bo.order;

import com.cloudkinto.bo.common.BaseQueryBo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang.StringUtils;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Date;

/**
 * 乐天查询条件
 *
 * @author long
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class OrderRakutenQueryBo extends BaseQueryBo {

    @ApiModelProperty("日期起")
    private String dateStart;

    @ApiModelProperty("日期止")
    private String dateEnd;

    @ApiModelProperty("sku（模糊查）")
    private String sku;

    @ApiModelProperty("订单编号")
    private String orderNumber;

    @ApiModelProperty("订单名称")
    private String orderName;

    @ApiModelProperty("系统备注")
    private String systemMemo;

    @ApiModelProperty("订单电话")
    private String orderPhone;

    @ApiModelProperty("发货类型")
    private String shipmentType;

    private String dateType;

    @ApiModelProperty("订单状态")
    private String orderProgress;

    private String shipType;

    @ApiModelProperty("是否发货")
    private String isSend;

    @ApiModelProperty("店铺id")
    private String shopId;

    public Date getDateStart() {
        if (StringUtils.isBlank(dateStart)){
            return null;
        }
        DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        LocalDateTime dateTime = LocalDate.parse(dateStart, format).atTime(0,0,0);
        return Date.from(dateTime.atZone(ZoneId.systemDefault()).toInstant());
    }
    public Date getDateEnd() {
        if (StringUtils.isBlank(dateEnd)){
            return null;
        }
        DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        LocalDateTime dateTime = LocalDate.parse(dateEnd, format).atTime(23,59,59);
        return Date.from(dateTime.atZone(ZoneId.systemDefault()).toInstant());
    }
}
